package com.atguigu.eduservice.controller.front;


import com.atguigu.commonutils.R;
import com.atguigu.eduservice.entity.EduCourse;
import com.atguigu.eduservice.entity.EduTeacher;
import com.atguigu.eduservice.service.EduCourseService;
import com.atguigu.eduservice.service.EduTeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 用户页面显示
 *
 */
@RestController
@RequestMapping("/eduservice/index")
@CrossOrigin
public class IndexController {

    @Autowired
    private EduCourseService courseService;

    @Autowired
    private EduTeacherService teacherService;

    //查询最新前4条讲师数据
    @GetMapping("/indexTeacherInfo")
    public R indexTeacherInfo()
    {
        List<EduTeacher> eduTeachers = teacherService.indexTeacherInfo();
        return R.ok().data("eduTeachers",eduTeachers);
    }

    //查询前8条课程数据
    @GetMapping("/indexCourseInfo")
    public R indexCourseInfo(){

        List<EduCourse> eduCourses = courseService.indexCourseInfo();
        return R.ok().data("eduCourses",eduCourses);
    }

}
